#pragma once

class CShading
{
private:
	typedef struct
	{
		D3DXHANDLE hTech;
		D3DXHANDLE hWVP;
		D3DXHANDLE hWorld;
		D3DXHANDLE hView;
		D3DXHANDLE hViewProj;
		D3DXHANDLE hViewInv;
		D3DXHANDLE hDiffuse;
		D3DXHANDLE hAmbient;
		D3DXHANDLE hSpecular;
	} BASE_HANDLE;

protected:
	LPD3DXEFFECT m_lpEffect;
	LPD3DXEFFECT m_lpDefaultEffect;
private:
	bool m_IsShader;
	IDirect3DVertexDeclaration9* m_lpDecl;
	BASE_HANDLE m_BaseHandle;
public:
	CShading();
	virtual ~CShading();

	void IsShader(bool bShader){m_IsShader = bShader;}
	bool IsShader(void){return m_IsShader;}

	void InitEffect(IDirect3DDevice9* pd3dDevice,const char* filename);
	void Init();
	void GetTechnique(const char *tec);
	D3DXHANDLE GetTechnique();

	void BindTechnique(LPD3DXEFFECT pEff);
	
	LPD3DXEFFECT GetEffect() {
		return m_lpEffect;
	}
	LPD3DXEFFECT GetDefaultEffect() {
		return m_lpDefaultEffect;
	}

	BASE_HANDLE& GetBaseHandle(){
		return m_BaseHandle;
	}
};